#include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int N = 110;
int n;
vector<int> edges[N];
int in[N];
int main()
{
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		int j = 0;
		while (cin >> j, j)
		{
			edges[i].push_back(j);
			in[j]++;
		}
	}
	queue<int> q;
	for (int i = 1;i <= n;i++)
	{
		if (in[i] == 0) q.push(i);
	}

	while (q. size())
	{
		int x = q.front();
		q.pop();
		cout << x << " ";

		for (auto y : edges[x])
		{
			in[y]--;
			if (in[y] == 0) q.push(y);
		}
	}
	return 0;
}